﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WS.EKA.Model;
using System.Data.SqlClient;

namespace WS.EKA.DataAccess
{
    public class MemberAddressContext:DBContext<MemberAddress>
    {
        public static void Add(MemberAddress address)
        {
            string sql = @"
INSERT INTO ShopNum1_Address
(
	[Guid],[Name],Email,[Address],Postalcode,Tel,Mobile,IsDefault,MemLoginID,
	CreateUser,CreateTime,ModifyUser,ModifyTime,IsDeleted,Code
	
)
VALUES
(
	NEWID(),@Name,@Email,@Address,@Postalcode,@Tel,@Mobile,@IsDefault,@MemLoginID,
	@CreateUser,GETDATE(),@ModifyUser,GETDATE(),0,@Code
) ";
            SqlParameter[] parameters = new SqlParameter[]
                {
                    new SqlParameter("@Name",address.NAME),
                    new SqlParameter("@Email",address.Email??string.Empty),
                    new SqlParameter("@Address",address.Address),
                    new SqlParameter("@Postalcode",address.Postalcode??string.Empty),
                    new SqlParameter("@Tel",address.Tel??string.Empty),
                    new SqlParameter("@Mobile",address.Mobile),
                    new SqlParameter("@IsDefault",address.IsDefault),
                    new SqlParameter("@MemLoginID",address.MemLoginID),
                    new SqlParameter("@CreateUser",address.CreateUser),
                    new SqlParameter("@ModifyUser",address.CreateUser),
                    new SqlParameter("@Code",address.Code?? string.Empty)
                };

            ExecSQL(sql, parameters);
        }
    }
}
